package org.hbnu.xiaomi.service;

import org.hbnu.xiaomi.entity.Carts;
import org.hbnu.xiaomi.mapper.CartsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CartsService implements CartsMapper {
    @Autowired
   CartsMapper cartsMapper;


    @Override
    public int insert(Carts cart) {
        return cartsMapper.insert(cart);
    }

    @Override
    public void update(Carts carts) {
        cartsMapper.update(carts);
    }


    @Override
    public void deleteById(int id) {
        cartsMapper.deleteById(id);
    }

    @Override
    public List<Carts> getByUsersId(int user_id) {
        return cartsMapper.getByUsersId(user_id);
    }

    @Override
    public Carts getById(int id) {
        return cartsMapper.getById(id);
    }

    @Override
    public void deleteByUserIdAndGoodId(Integer user_id, Integer good_id) {
        cartsMapper.deleteByUserIdAndGoodId(user_id,good_id);
    }

    @Override
    public Integer getNumByGoodIdAndUserId(Integer good_id, Integer user_id) {
        return cartsMapper.getNumByGoodIdAndUserId(good_id,user_id);
    }


}
